* Produce Table 1 (list of events), Table B.2.

preserve
ren year devaluationYear
sort ccode
tostring devaluationYear, replace
keep if largeDevaluation==1
sort P country devaluationYear
capture export excel country devaluationYear P using "`1'/TableB2.xlsx" if largeDevaluation==1, sh("RER Measure By Episode") first(var) replace 
keep countryname devaluationYear
sort countryname devaluationYear
bys countryname: gen epis = _n
egen id = group(countryname)
reshape wide devaluationYear, i(id) j(epis)
drop id
order countryname, first
sort countryname
capture export excel "`1'/Table1.xlsx" , sh("Table 1") first(var) replace
restore
preserve
keep ccode year largeDevaluation country gRER acce* gER countryname P 
keep if largeDevaluation==1
bys country: gen counter=_n
keep if counter==1
sort P country
capture export excel country P using "`1'/TableB2.xlsx", sh("RER Measure By Country") first(var) 
restore
